
layui.use(['layer','table','laydate'],function(){
    $ = layui.jquery;
    var layer = layui.layer ,table = layui.table,laydate = layui.laydate;
    //第一个实例
    table.render({
        elem: '#demo'
        ,height: "auto"
        ,method:"post"
        ,url: baseUrl+'change/getrooms?roomName=' //数据接口
        ,request: {
            pageName: 'pageNum' //页码的参数名称，默认：page
            ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
        }
        ,page: false //开启分页
        ,cols: [[ //表头
             {field:"roomName", title: '房间号',align:'center'}
            ,{field: "personnum", title: '人数',align:'center'}
            ,{field:"num" , title: '局数',align:'center'}
            ,{fixed: 'right',   title: '操作', width:150, align:'center', toolbar: '#barDemo'}
        ]]
    });
    //监听工具条
    table.on('tool(test)', function(obj){
        var data = obj.data;
        var layEvent = obj.event;
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        if(layEvent === 'let') { //编辑
            var index = layui.layer.open({
                title: "房间"+data.roomName+"的详细信息",
                type: 2,
                area: ["1200px","800px"],
                content: "usercards.html",
                success: function (layero, index) {
                    var body = layui.layer.getChildFrame('body', index);
                    body.find("#roomName").val(data.roomName);
                    setTimeout(function () {
                        layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    }, 300)
                }
            });
        }
    });

})

